#! /usr/bin/env python
#coding=utf-8

HOST = 'localhost'
PORT = 8080
MAX_RETRY_TIMES = 3
TIMEOUT = 4
TOKEN = ''
TLDS = ['gs', 'gy', 'gg', 'gd', 'edu', 'gl', 'gi', 'xn--kprw13d', 'tz', 'tv',
        'tw', 'tr', 'tn', 'to', 'tl', 'xn--lgbbat1ad8j', 'tk', 'th', 'tf',
        'xn--clchc0ea0b2g2a9gcd', 'tc', 'coop', 'dk', 'de', 'dz',
        'xn--mgb9awbf', 'gov', 'qa', 'tel', 'asia', 'net', 'xn--3e0b707e',
        'wf', 'jobs', 'jp', 'ws', 'je', 'com', 'ci', 'ch', 'co', 'cn', 'cl',
        'cc', 'arpa', 'ca', 'xn--kpry57d', 'cz', 'cx', 'pr', 'pt', 'int',
        'tm', 'pe', 'pl', 'pm', 'aero', 'me', 'md', 'mg', 'ma', 'mo', 'mn',
        'cat', 'mu', 'mp', 'ms', 'my', 'mx', 'vc', 've', 'vg', 'iq', 'is',
        'ir', 'it', 'dm', 'im', 'il', 'io', 'in', 'ie', 'travel', 'fr',
        'xn--fiqs8s', 'xn--mgberp4a5d4ar', 'fi', 'fo', 'sx', 'xn--yfro4i67o',
        'su', 'st', 'sk', 'si', 'sh', 'so', 'sn', 'sm', 'sc', 'sb', 'sa',
        'sg', 'se', 'la', 'xn--80ao21a', 'xn--fiqz9s', 'li', 'lv', 'lt', 'lu',
        'ly', 'biz', 'yt', 'name', 'ee', 'ec', 'eu', 'xn--wgbl6a', 'es', 'ru',
        'rs', 're', 'ro', 'be', 'bg', 'bo', 'bi', 'bj', 'br', 'org', 'post',
        'by', 'om', 'xn--mgbaam7a8h', 'xn--j6w193g', 'museum', 'hr', 'ht',
        'hu', 'hk', 'xn--o3cw4h', 'mobi', 'hn', 'info', 'uy', 'uz', 'us',
        'uk', 'ug', 'ua', 'ac', 'ae', 'ag', 'af', 'ai', 'pro', 'am', 'as',
        'au', 'at', 'nl', 'no', 'na', 'nc', 'nf', 'ng', 'nz', 'nu', 'xxx',
        'kg', 'ke', 'ki', 'kr', 'xn--ygbi2ammx', 'xn--p1ai', 'kz']

WHOIS_SERVER = {
    "ac": "whois.nic.ac",
    "ae": "whois.aeda.net.ae",
    "aero": "whois.aero",
    "af": "whois.nic.af",
    "ag": "whois.nic.ag",
    "ai": "whois.ai",
    "am": "whois.amnic.net",
    "arpa": "whois.iana.org",
    "as": "whois.nic.as",
    "asia": "whois.nic.asia",
    "at": "whois.nic.at",
    "au": "whois.audns.net.au",
    "be": "whois.dns.be",
    "bg": "whois.register.bg",
    "bi": "whois1.nic.bi",
    "biz": "whois.biz",
    "bj": "whois.nic.bj",
    "bo": "whois.nic.bo",
    "br": "whois.registro.br",
    "by": "whois.cctld.by",
    "ca": "whois.cira.ca",
    "cat": "whois.cat",
    "cc": "ccwhois.verisign-grs.com",
    "ch": "whois.nic.ch",
    "ci": "whois.nic.ci",
    "cl": "whois.nic.cl",
    "cn": "whois.cnnic.cn",
    "co": "whois.nic.co",
    "com": "whois.verisign-grs.com",
    "coop": "whois.nic.coop",
    "cx": "whois.nic.cx",
    "cz": "whois.nic.cz",
    "de": "whois.denic.de",
    "dk": "whois.dk-hostmaster.dk",
    "dm": "whois.nic.dm",
    "dz": "whois.nic.dz",
    "ec": "whois.nic.ec",
    "edu": "whois.educause.edu",
    "ee": "whois.tld.ee",
    "es": "whois.nic.es",
    "eu": "whois.eu",
    "fi": "whois.fi",
    "fo": "whois.nic.fo",
    "fr": "whois.nic.fr",
    "gd": "whois.adamsnames.com",
    "gg": "whois.gg",
    "gi": "whois2.afilias-grs.net",
    "gl": "whois.nic.gl",
    "gov": "whois.dotgov.gov",
    "gs": "whois.nic.gs",
    "gy": "whois.registry.gy",
    "hk": "whois.hkirc.hk",
    "hn": "whois2.afilias-grs.net",
    "hr": "whois.dns.hr",
    "ht": "whois.nic.ht",
    "hu": "whois.nic.hu",
    "ie": "whois.domainregistry.ie",
    "il": "whois.isoc.org.il",
    "im": "whois.nic.im",
    "info": "whois.afilias.net",
    "in": "whois.inregistry.net",
    "int": "whois.iana.org",
    "io": "whois.nic.io",
    "iq": "whois.cmc.iq",
    "ir": "whois.nic.ir",
    "is": "whois.isnic.is",
    "it": "whois.nic.it",
    "je": "whois.je",
    "jobs": "jobswhois.verisign-grs.com",
    "jp": "whois.jprs.jp",
    "ke": "whois.kenic.or.ke",
    "kg": "whois.domain.kg",
    "ki": "whois.nic.ki",
    "kr": "whois.kr",
    "kz": "whois.nic.kz",
    "la": "whois.nic.la",
    "li": "whois.nic.li",
    "lt": "whois.domreg.lt",
    "lu": "whois.dns.lu",
    "lv": "whois.nic.lv",
    "ly": "whois.nic.ly",
    "ma": "whois.iam.net.ma",
    "md": "whois.nic.md",
    "me": "whois.nic.me",
    "mg": "whois.nic.mg",
    "mn": "whois.nic.mn",
    "mobi": "whois.dotmobiregistry.net",
    "mo": "whois.monic.mo",
    "mp": "whois.nic.mp",
    "ms": "whois.nic.ms",
    "mu": "whois.nic.mu",
    "museum": "whois.museum",
    "mx": "whois.mx",
    "my": "whois.domainregistry.my",
    "na": "whois.na-nic.com.na",
    "name": "whois.nic.name",
    "nc": "whois.nc",
    "net": "whois.verisign-grs.com",
    "nf": "whois.nic.net.nf",
    "ng": "whois.nic.net.ng",
    "nl": "whois.domain-registry.nl",
    "no": "whois.norid.no",
    "nu": "whois.nic.nu",
    "nz": "whois.srs.net.nz",
    "om": "whois.registry.om",
    "org": "whois.pir.org",
    "pe": "kero.yachay.pe",
    "pl": "whois.dns.pl",
    "pm": "whois.nic.pm",
    "post": "whois.dotpostregistry.net",
    "pr": "whois.nic.pr",
    "pro": "whois.dotproregistry.net",
    "pt": "whois.dns.pt",
    "qa": "whois.registry.qa",
    "re": "whois.nic.re",
    "ro": "whois.rotld.ro",
    "rs": "whois.rnids.rs",
    "ru": "whois.tcinet.ru",
    "sa": "whois.nic.net.sa",
    "sb": "whois.nic.net.sb",
    "sc": "whois2.afilias-grs.net",
    "se": "whois.iis.se",
    "sg": "whois.sgnic.sg",
    "sh": "whois.nic.sh",
    "si": "whois.arnes.si",
    "sk": "whois.sk-nic.sk",
    "sm": "whois.nic.sm",
    "sn": "whois.nic.sn",
    "so": "whois.nic.so",
    "st": "whois.nic.st",
    "su": "whois.tcinet.ru",
    "sx": "whois.sx",
    "tc": "whois.adamsnames.tc",
    "tel": "whois.nic.tel",
    "tf": "whois.nic.tf",
    "th": "whois.thnic.co.th",
    "tk": "whois.dot.tk",
    "tl": "whois.nic.tl",
    "tm": "whois.nic.tm",
    "tn": "whois.ati.tn",
    "to": "whois.tonic.to",
    "travel": "whois.nic.travel",
    "tr": "whois.nic.tr",
    "tv": "tvwhois.verisign-grs.com",
    "tw": "whois.twnic.net.tw",
    "tz": "whois.tznic.or.tz",
    "ua": "whois.ua",
    "ug": "whois.co.ug",
    "uk": "whois.nic.uk",
    "us": "whois.nic.us",
    "uy": "whois.nic.org.uy",
    "uz": "whois.cctld.uz",
    "vc": "whois2.afilias-grs.net",
    "ve": "whois.nic.ve",
    "vg": "whois.adamsnames.tc",
    "wf": "whois.nic.wf",
    "ws": "whois.website.ws",
    "xn--3e0b707e": "whois.kr",
    "xn--80ao21a": "whois.nic.kz",
    "xn--clchc0ea0b2g2a9gcd": "whois.sgnic.sg",
    "xn--fiqs8s": "cwhois.cnnic.cn",
    "xn--fiqz9s": "cwhois.cnnic.cn",
    "xn--j6w193g": "whois.hkirc.hk",
    "xn--kprw13d": "whois.twnic.net.tw",
    "xn--kpry57d": "whois.twnic.net.tw",
    "xn--lgbbat1ad8j": "whois.nic.dz",
    "xn--mgb9awbf": "whois.registry.om",
    "xn--mgbaam7a8h": "whois.aeda.net.ae",
    "xn--mgberp4a5d4ar": "whois.nic.net.sa",
    "xn--o3cw4h": "whois.thnic.co.th",
    "xn--p1ai": "whois.tcinet.ru",
    "xn--wgbl6a": "whois.registry.qa",
    "xn--yfro4i67o": "whois.sgnic.sg",
    "xn--ygbi2ammx": "whois.pnina.ps",
    "xxx": "whois.nic.xxx",
    "yt": "whois.nic.yt",
}

RE_NO_MATCH_INFO = {
    "gs": "Status: Not Registered",
    "gy": "Status: Not Registered",
    "gg": "Status: Not Registered",
    "gd": "not found",
    "gl": "Status: Not Registered",
    "gl": "Status: Not Registered",
    "gi": "NOT FOUND",
    "tz": "No entries found",
    "tv": "No match for",
    "tn": "Domain .*? not found",
    "to": "No match for",
    "tl": "Status: Not Registered",
    "tk": "Invalid query or domain name not known in Dot TK Domain Registry",
    "th": "No match for",
    "tf": "No entries found in the AFNIC Database.",
    "xn--clchc0ea0b2g2a9gcd": "Domain Not Found",
    "tc": "not found",
    "coop": "No domain records were found to match",
    "dk": "No entries found for the selected source",
    "de": "Status: free",
    "xn--mgb9awbf": "No Data Found",
    "gov": "No match for",
    "qa": "No Data Found",
    "tel": "Not found",
    "asia": "NOT FOUND",
    "net": "No match for",
    "xn--3e0b707e": "Above domain name is not registered to KRNIC.",
    "wf": "No entries found in the AFNIC Database.",
    "jobs": "No match for",
    "ws": "No match for",
    "je": "Status: Not Registered",
    "com": "No match for",
    "ci": "Domain .*? not found",
    "co": "Not found: ",
    "cn": "no matching record",
    "cc": "No match for",
    "ca": "Domain status:         available",
    "cz": "No entries found",
    "cx": "Status: Not Registered",
    "tm": "Domain .*? - Available",
    "pe": "Status: Not Registered",
    "pl": "No information available about domain name .*?.pl in the Registry NASK database.",
    "pm": "%% No entries found in the AFNIC Database.",
    "aero": "NOT FOUND",
    "me": "NOT FOUND",
    "mg": "Status: Not Registered",
    "ma": "error 230 No Objects Found",
    "mo": "No match for",
    "cat": "Object .*? NOT FOUND",
    "mu": "Status: Not Registered",
    "ms": "Status: Not Registered",
    "my": "Domain Name .*? does not exist in database",
    "mx": "No_Se_Encontro_El_Objeto/Object_Not_Found",
    "vc": "NOT FOUND",
    "ve": "No match for",
    "vg": "not found",
    "iq": "Status: Not Registered",
    "is": "No entries found for query",
    "pr": "The domain .*?.pr is not registered.",
    "pt": "No match for",
    "ir": "no entries found",
    "it": "Status:             AVAILABLE",
    "dm": "not found...",
    "im": "The domain .*?  was not found",
    "il": "No data was found to match the request criteria.",
    "io": "Domain .*? - Available",
    "in": "NOT FOUND",
    "ie": "Not Registered - The domain you have requested .*? is not a registered .ie domain name.",
    "travel": "Not found: ",
    "fr": "No entries found in the AFNIC Database.",
    "xn--fiqs8s": "no matching record",
    "fi": "Domain not found",
    "fo": "no entries found",
    "sx": "Status: reserved/free (policy pending)",
    "su": "No entries found for the selected source(s).",
    "st": "No entries found for domain",
    "sk": "Not found.",
    "si": "% No entries found for the selected source(s).",
    "sh": "Domain .*? - Available",
    "so": "Not found: ",
    "sm": "No entries found.",
    "sc": "NOT FOUND",
    "sb": "Status: Not Registered",
    "sa": "No Match for",
    "sg": "Domain Not Found",
    "se": ".*? not found",
    "la": "DOMAIN NOT FOUND",
    "xn--80ao21a": "Nothing found for this query.",
    "xn--fiqz9s": "no matching record",
    "li": "We do not have an entry in our database matching your query.",
    "lv": "Status: free",
    "lt": "Status:			available",
    "lu": "No such domain",
    "ly": "Not found",
    "biz": "Not found:",
    "yt": "No entries found in the AFNIC Database.",
    "name": "No match.",
    "ee": "No entries found. ",
    "eu": "Status:	AVAILABLE",
    "xn--wgbl6a": "No Data Found",
    "ru": "No entries found for the selected source(s)",
    "rs": "ERROR:103: Domain is not registered",
    "re": "No entries found in the AFNIC Database.",
    "ro": "No entries found for the selected source(s).",
    "be": "Status:	AVAILABLE",
    "bg": "Domain name .*? does not exist in database!",
    "bi": "Status: Not Registered",
    "bj": "No records matching .*?  found",
    "br": "No match for domain",
    "org": "NOT FOUND",
    "by": "Object does not exist",
    "om": "No Data Found",
    "xn--mgbaam7a8h": "No Data Found",
    "museum": "Object .*? NOT FOUND.",
    "ht": "Status: Not Registered",
    "hu": "No match",
    "xn--o3cw4h": "No match for",
    "mobi": "NOT FOUND",
    "hn": "NOT FOUND",
    "info": "NOT FOUND",
    "uy": "No match for",
    "uz": "Sorry, but domain: .*?, not found in database",
    "us": "Not found: ",
    "ug": "No entries found for the selected source(s).",
    "ua": "No entries found for",
    "ac": "Domain .*? - Available",
    "ae": "No Data Found",
    "ag": "NOT FOUND",
    "af": "Status: Not Registered",
    "ai": "Domain .*? not registred.",
    "pro": "NOT FOUND",
    "am": "No match",
    "as": "Domain Not Found",
    "au": "No Data Found",
    "at": "nothing found",
    "nl": ".*? is free",
    "no": "No match",
    "na": "Status: Not Registered",
    "nc": "No entries found in the .nc database",
    "nf": "Status: Not Registered",
    "ng": "Status: Not Registered",
    "nu": "NO MATCH for domain",
    "kg": "Data not found. This domain is available for registration.",
    "ke": "Status: Not Registered",
    "ki": "Domain Status: Available",
    "kr": "Above domain name is not registered to KRNIC.",
    "xn--ygbi2ammx": "Status: Not Registered",
    "xn--p1ai": "No entries found for the selected source(s).",
    "kz": "Nothing found for this query.",
    "edu": "No Match"
}


NO_MATCH_INFO = {
    "gs": "Status: Not Registered",
    "gy": "Status: Not Registered",
    "gg": "Status: Not Registered",
    "gd": "not found",
    "gl": "Status: Not Registered",
    "gl": "Status: Not Registered",
    "gi": "NOT FOUND",
    "tz": "No entries found",
    "tv": "No match for",
    "tn": " not found",
    "to": "No match for",
    "tl": "Status: Not Registered",
    "tk": "Invalid query or domain name not known in Dot TK Domain Registry",
    "th": "No match for",
    "tf": "No entries found in the AFNIC Database.",
    "xn--clchc0ea0b2g2a9gcd": "Domain Not Found",
    "tc": "not found",
    "coop": "No domain records were found to match",
    "dk": "No entries found for the selected source",
    "de": "Status: free",
    "xn--mgb9awbf": "No Data Found",
    "gov": "No match for",
    "qa": "No Data Found",
    "tel": "Not found",
    "asia": "NOT FOUND",
    "net": "No match for",
    "xn--3e0b707e": "Above domain name is not registered to KRNIC.",
    "wf": "No entries found in the AFNIC Database.",
    "jobs": "No match for",
    "ws": "No match for",
    "je": "Status: Not Registered",
    "com": "No match for",
    "ci": " not found",
    "co": "Not found: ",
    "cn": "no matching record",
    "cc": "No match for",
    "ca": "Domain status:         available",
    "cz": "No entries found",
    "cx": "Status: Not Registered",
    "tm": " - Available",
    "pe": "Status: Not Registered",
    "pl": "No information available about domain name",
    "pm": "%% No entries found in the AFNIC Database.",
    "aero": "NOT FOUND",
    "me": "NOT FOUND",
    "mg": "Status: Not Registered",
    "ma": "error 230 No Objects Found",
    "mo": "No match for",
    "cat": " NOT FOUND",
    "mu": "Status: Not Registered",
    "ms": "Status: Not Registered",
    "my": " does not exist in database",
    "mx": "No_Se_Encontro_El_Objeto/Object_Not_Found",
    "vc": "NOT FOUND",
    "ve": "No match for",
    "vg": "not found",
    "iq": "Status: Not Registered",
    "is": "No entries found for query",
    "pr": ".pr is not registered.",
    "pt": "No match for",
    "ir": "no entries found",
    "it": "Status:             AVAILABLE",
    "dm": "not found...",
    "im": "  was not found",
    "il": "No data was found to match the request criteria.",
    "io": " - Available",
    "in": "NOT FOUND",
    "ie": " is not a registered .ie domain name.",
    "travel": "Not found: ",
    "fr": "No entries found in the AFNIC Database.",
    "xn--fiqs8s": "no matching record",
    "fi": "Domain not found",
    "fo": "no entries found",
    "sx": "Status: reserved/free (policy pending)",
    "su": "No entries found for the selected source(s).",
    "st": "No entries found for domain",
    "sk": "Not found.",
    "si": "% No entries found for the selected source(s).",
    "sh": " - Available",
    "so": "Not found: ",
    "sm": "No entries found.",
    "sc": "NOT FOUND",
    "sb": "Status: Not Registered",
    "sa": "No Match for",
    "sg": "Domain Not Found",
    "se": ".*? not found",
    "la": "DOMAIN NOT FOUND",
    "xn--80ao21a": "Nothing found for this query.",
    "xn--fiqz9s": "no matching record",
    "li": "We do not have an entry in our database matching your query.",
    "lv": "Status: free",
    "lt": "Status:			available",
    "lu": "No such domain",
    "ly": "Not found",
    "biz": "Not found:",
    "yt": "No entries found in the AFNIC Database.",
    "name": "No match.",
    "ee": "No entries found. ",
    "eu": "Status:	AVAILABLE",
    "xn--wgbl6a": "No Data Found",
    "ru": "No entries found for the selected source(s)",
    "rs": "ERROR:103: Domain is not registered",
    "re": "No entries found in the AFNIC Database.",
    "ro": "No entries found for the selected source(s).",
    "be": "Status:	AVAILABLE",
    "bg": " does not exist in database!",
    "bi": "Status: Not Registered",
    "bj": "No records matching ",
    "br": "No match for domain",
    "org": "NOT FOUND",
    "by": "Object does not exist",
    "om": "No Data Found",
    "xn--mgbaam7a8h": "No Data Found",
    "museum": " NOT FOUND.",
    "ht": "Status: Not Registered",
    "hu": "No match",
    "xn--o3cw4h": "No match for",
    "mobi": "NOT FOUND",
    "hn": "NOT FOUND",
    "info": "NOT FOUND",
    "uy": "No match for",
    "uz": " not found in database",
    "us": "Not found: ",
    "ug": "No entries found for the selected source(s).",
    "ua": "No entries found for",
    "ac": " - Available",
    "ae": "No Data Found",
    "ag": "NOT FOUND",
    "af": "Status: Not Registered",
    "ai": " not registred.",
    "pro": "NOT FOUND",
    "am": "No match",
    "as": "Domain Not Found",
    "au": "No Data Found",
    "at": "nothing found",
    "nl": "is free",
    "no": "No match",
    "na": "Status: Not Registered",
    "nc": "No entries found in the .nc database",
    "nf": "Status: Not Registered",
    "ng": "Status: Not Registered",
    "nu": "NO MATCH for domain",
    "kg": "Data not found. This domain is available for registration.",
    "ke": "Status: Not Registered",
    "ki": "Domain Status: Available",
    "kr": "Above domain name is not registered to KRNIC.",
    "xn--ygbi2ammx": "Status: Not Registered",
    "xn--p1ai": "No entries found for the selected source(s).",
    "kz": "Nothing found for this query.",
    "edu": "No match for"
}
